package com.gitee.wsl.mathematics.vector


interface MutableVector<T:Number,V: Vector<T, V>>: Vector<T, V>,VectorModifyContainer<T,V> {

    override var length:T

    //operator fun divAssign(other: V) = proxy.updateIndexed { index, t -> t / other.proxy[index] }

    //operator fun timesAssign(other: V) = proxy.updateIndexed { index, t -> t * other.proxy[index] }

    fun negate() =  proxy.updateIndexed { _, t -> -t  }

    fun norm(){
        val l = length
        return if (l != zero) {
            scale(l.divBy(1f))
        } else {
            clear()
        }
    }

    fun scale(factor: T) = proxy.update {  t -> t * factor }

    /*fun set(other:V) = proxy.updateIndexed { index, _ -> other.proxy[index] }

    fun clear() = proxy.fill(zero)

    fun abs()   = proxy.update {  t -> abs(t) }
    fun sign()  = proxy.update {  t -> sign(t) }
    fun ceil()  = proxy.update {  t -> ceil(t) }
    fun floor() = proxy.update {  t -> floor(t) }
    fun round() = proxy.update {  t -> round(t) }

    operator fun timesAssign(v: Number) = proxy.update {  t -> t * v }

    operator fun divAssign(v: Number) = proxy.update {  t -> t / v }

    fun subtract(other: V) = proxy.updateIndexed { index, t -> t - other.proxy[index] }

    fun scale(factor: T) = timesAssign(factor)

    operator fun plusAssign(other: V) = proxy.updateIndexed { index, t -> t + other.proxy[index] }*/

}



interface MutableVectorF<V: Vector<Float, V>> :  MutableVector<Float, V>,VectorF<V>{

}

interface MutableVectorD<V: Vector<Double, V>> :  MutableVector<Double, V>,VectorD<V> {

}

/*inline fun <T:Number,V: Vector<T, V>, M: MutableVector<T, V>> M.update(block: M.()->Unit):M {
    block()
    return this
}*/
